import unittest
# 导入封装的包
from ddt import ddt, file_data

from unit__001.unit_01.excel import excel
# 导入相关post的封装方法
from unit__001.unit_02.Tools import post

path = r'/unit__001/unit_01\excel.xlsx'
sheetname = 'Sheet1'
dy = excel(path, sheetname)


@ddt
class A3mall(unittest.TestCase):
    def setUp(self) -> None:
        print('start case')

    def tearDown(self) -> None:
        print('end case')

    # 注册
    def test_A3mall_01(self):
        url = 'http://10.59.9.14:7003/api/register'
        data = {'username': '18185603006', 'password': '123456'}
        # 调用封装post的方法
        register = post(url=url, data=data)
        print(register)

    token = None

    # 登录
    @file_data('data.yaml')
    def test_A3mall_02(self, username, password):
        url = 'http://10.59.9.14:7003/api/public/login'
        data = {
            "username": username,
            "password": password
        }
        # 调用封装post的方法
        login = post(url=url, data=data)
        print(login)


if __name__ == '__main__':
    unittest.main()
